package com.aaa.dang.common.exceptionhandle;

import com.aaa.dang.common.systemconst.ISystemConst;
import com.aaa.dang.common.util.ResultModel;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.transform.Result;

/**
 * @author JinChaoLiang
 * @calss QY87
 * @description 描述全局捕获异常处理
 * @date 2019/1/2
 */
@ControllerAdvice
public class ExceptionHandle {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public ResultModel errorHandle(Exception e) {
        ResultModel rm = new ResultModel();
        rm.setData("");
        rm.setCode(ISystemConst.EXCEPTION_HANDLE);
        rm.setMsg("对不起，要访问的内容出错了！"+e.getMessage());
        return rm;
    }
}
